package com.ysp;

import java.lang.reflect.InvocationHandler;
import java.lang.reflect.Method;
import java.lang.reflect.Proxy;

/**
 * @author ysp
 * @date 2021/1/11 10:20
 */
public class Main {

    public static void main(String[] args) {

        System.getProperties().put("jdk.proxy.ProxyGenerator.saveGeneratedFiles", "true");

        //是如何创建的打理对象实例的？？？
        Move o = (Move)Proxy.newProxyInstance(Target.class.getClassLoader(), new Class[]{Move.class},
                new InvocationHandler() {
                    @Override
                    public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
                        System.out.println("代理开始");
                        Object invoke = method.invoke(new Ta(), null);
                        System.out.println("代理结束");
                        return invoke;
                    }
                }
        );
        o.move();
    }
}
